package phonedata;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class FlowReduce extends Reducer<Text, FlowBean, Text, FlowBean> {
    public void reduce(Text key, Iterable<FlowBean> values, Context context) throws IOException, InterruptedException {
        long allUp = 0, allDown = 0;
        for (FlowBean value : values) {
            allUp += value.getUpFlow();
            allDown += value.getDownFlow();
        }
        context.write(key, new FlowBean(allUp, allDown));
    }
}
